package design_8_filter.demo1.filter.impl;

import design_8_filter.demo1.entity.User;
import design_8_filter.demo1.filter.UserFilter;

import java.util.ArrayList;
import java.util.List;

/**
  * 过滤 离职 的数据
  * @author wangsong
  * @email  1720696548@qq.com
  * @date  2022/4/14 18:42
  */
public class UserStateFilter implements UserFilter {

	private UserFilter userFilter;

	public UserStateFilter(UserFilter userFilter) {
		this.userFilter = userFilter;
	}

	@Override
	public List<User> filter(List<User> users) {
		List<User> newUsers = new ArrayList<>();
		for (User user : users) {
			if(user.getState() != 1){
				newUsers.add(user);
			}
		}
		return userFilter.filter(newUsers);
	}
}